<template>
  <div class="nav">
    <div class="left">
      <ul>
        <li @click="navChange(-1, 'all')" :class="active == -1 ? 'active' : ''">推荐</li>
        <li :class="active == i ? 'active' : ''" v-for="(item, i) in navList" :key="item.cate2Id" @click="navChange(i, item.shortName)">
          {{ item.name }}
        </li>
      </ul>
    </div>
    <div class="right" @click="menu">
        <span class="iconfont icon-gengduo"></span>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    navList: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  data() {
      return {
          active: -1,
      }
  },
  methods: {
      navChange(i, item) {
          this.active = i
          this.$emit('navChange', i, item)
      },
      menu() {
        this.$emit('menu')
      }
  }
};
</script>

<style lang="scss" scoped>
.nav {
    display: flex;
    align-items: center;
    font-size: .32rem;
}
.left {
  width: calc(100% - 1rem);
  overflow-x: scroll;
  overflow-y: hidden;
  ul {
    list-style: none;
    display: flex;
    width: 20rem;
    height: 1rem;
    li {
      width: 5rem;
      height: 100%;
      text-align: center;
      line-height: 1rem;
    }
    .active {
        font-weight: bold;
        color: #ff5d23;
        border-bottom: 2px solid #ff5d23;
    }
  }
}
.right {
    padding-left: .2rem;
}
</style>